package com.zwxu.cas.web.authentication.handler;

import java.security.GeneralSecurityException;

import org.jasig.cas.authentication.AbstractAuthenticationHandler;
import org.jasig.cas.authentication.BasicCredentialMetaData;
import org.jasig.cas.authentication.Credential;
import org.jasig.cas.authentication.HandlerResult;
import org.jasig.cas.authentication.PreventedException;
import org.jasig.cas.authentication.principal.SimplePrincipal;

import com.zwxu.cas.web.authentication.principal.CasCredential;

public class UserPwdAuthenticationHandler extends AbstractAuthenticationHandler{


	@Override
	public HandlerResult authenticate(Credential credential) throws GeneralSecurityException, PreventedException {
		CasCredential casCredential = (CasCredential) credential;
		String username = casCredential.getUsername();
		SimplePrincipal simplePrincipal = new SimplePrincipal(username);
        return new HandlerResult(this, new BasicCredentialMetaData(casCredential), simplePrincipal, null);
	}

	@Override
	public boolean supports(Credential credential) {
		// TODO Auto-generated method stub
		return true;
	}

}
